package com.skeletonee.web.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.skeletonee.service.example.FooManager;

public class ExampleServlet extends HttpServlet{

	private static final long serialVersionUID = 1L;
	
	public void doGet( HttpServletRequest req,HttpServletResponse resp) throws IOException{
		doPost( req,resp );
	}
	
	public void doPost( HttpServletRequest req,HttpServletResponse resp) throws IOException{
		ApplicationContext ctx = 
	        WebApplicationContextUtils.getRequiredWebApplicationContext( super.getServletContext() );
		FooManager fooManager = (FooManager)ctx.getBean("fooManager");
		fooManager.get("root");

		resp.getWriter().print("run here...");
		resp.getWriter().flush();
	}	

}
